package com.aids_malaria.db.dao;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;

import com.aids_malaria.http.response.WorkAreaPersonID;

import java.util.List;

@Dao
public interface WorkAreaPersonIDDao {
    @Query("delete from workAreaPersonID")
    int deleteAll();

    @Query("delete from workAreaPersonID WHERE isDownload = :isDownload")
    int deleteAllDownLoadStatus(int isDownload);

    @Query("SELECT * FROM workAreaPersonID")
    List<WorkAreaPersonID> getAll();

    @Query("SELECT * FROM workAreaPersonID WHERE isDownload = :isDownload")
    List<WorkAreaPersonID> getAllDownLoadStatus(int isDownload);

    @Query("SELECT * FROM workAreaPersonID WHERE identity_code = :identity_code LIMIT 1")
    WorkAreaPersonID getByIdentityCode(String identity_code);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    List<Long> insertAll(List<WorkAreaPersonID> users);

    @Update()
    int update(WorkAreaPersonID workAreaPersonID);

    @Update()
    int update(WorkAreaPersonID... workAreaPersonID);

    @Query("UPDATE workAreaPersonID SET isDownload=:isDownload WHERE identity_code = :identity_code")
    void update(int isDownload, String identity_code);

}
